<template>
    <el-dialog
      :close-on-click-modal="false"
      :visible.sync="showSelectUser"
      :before-close="cancel"
      v-if="showSelectUser"
      title="选择用户"
      width="820px"
    >
      <div>
        <div>
          <!--工具栏-->
          <div class="head-container">
            <div v-if="crud.props.searchToggle">
              <!-- 搜索 -->
              <el-input v-model="query.username" clearable size="small" placeholder="输入关键字查询" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery" />
              <rrOperation />
            </div>
          </div>

          <!--表格渲染-->
          <el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row style="width: 100%;">
            <el-table-column type="selection" width="55" />      
            <el-table-column prop="nickname" label="用户名" />
            <el-table-column prop="username" label="登录名" />
            <el-table-column prop="phone" label="电话" />
          </el-table>
          <!--分页组件-->
          <pagination />

          <div slot="footer" class="dialog-footer">
            <el-button type="text" @click="confirmSelect">确定</el-button>
            <el-button type="text" @click="cancel">取消</el-button>
          </div>      
        </div>
      </div>
  </el-dialog>
</template>

<script>
import crudUser from '@/api/system/user'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import pagination from '@crud/Pagination'
import rrOperation from '@crud/RR.operation'
import udOperation from '@crud/UD.operation'

//const defaultForm = { id: null, userid: null, acl: null, userName: null }

export default {
  name: 'selectUser',
  components: { pagination, rrOperation, udOperation, crudUser },
  cruds() {
    return CRUD({ title: '用户', url: 'sys/user', crudMethod: { ...crudUser }})
  },
  props: {
    showSelectUser: {
      type: Boolean,
      required: true,
      default:false
    }
  },    
  mixins: [
    presenter(),
    header(),
    // form(defaultForm),
    crud()],
  data() {
    return {
      rules: {
      },
      permission: {
      }
    }
  },
  methods: {
    confirmSelect() {
      this.$emit('hideSelectUser')
      this.$emit('selectUserCallBack', this.$refs.table.selection)
    },
    cancel() {
      this.$emit('hideSelectUser')
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
 ::v-deep .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
